package com.liumuxian.exam.service.impl;


import com.liumuxian.exam.dao.ExamPerformanceDataDao;
import com.liumuxian.exam.dao.QuestionDao;
import com.liumuxian.exam.pojo.ExamPerformance;
import com.liumuxian.exam.pojo.ExamPerformanceData;
import com.liumuxian.exam.service.ExamPerformanceDataService;
import com.liumuxian.exam.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
public class ExamPerformanceDataServiceImpl  implements ExamPerformanceDataService {
    @Autowired
    private ExamPerformanceDataDao examPerformanceDataDao;
    @Autowired
    private QuestionDao questionDao;
    public ExamPerformanceData findByExamperformanceidAndQuestionid(String examperformanceid,String questionid){
        ExamPerformanceData examPerformance = examPerformanceDataDao.findByExamperformanceidAndQuestionidAndState(examperformanceid,questionid,1);
        return toExamPerformanceData(examPerformance);
    }
    private ExamPerformanceData toExamPerformanceData(ExamPerformanceData examPerformanceData){
        examPerformanceData.setQuestion(questionDao.findById(examPerformanceData.getQuestionid()).get());
        return examPerformanceData;
    }
}
